# Contributor: Andy Postnikov <apostnikov@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>

pkgname=php7-pecl-igbinary
_pkgreal=igbinary
pkgver=3.1.4
pkgrel=0
pkgdesc="Igbinary is a drop in replacement for the standard php serializer"
url="https://pecl.php.net/package/igbinary"
arch="all"
license="BSD-3-Clause"
provides="php7-igbinary=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-igbinary" # for backward compatibility
depends="php7-common"
makedepends="php7-dev php7-pecl-apcu"
checkdepends="php7-json php7-session" # sessions needs work https://github.com/igbinary/igbinary/issues/116
source="$pkgname-$pkgver.tgz::https://pecl.php.net/get/$_pkgreal-$pkgver.tgz"
builddir="$srcdir/$_pkgreal-$pkgver"

build() {
	phpize7
	./configure \
		--prefix=/usr \
		--with-php-config=/usr/bin/php-config7
	make
}

check() {
	local modules="/usr/lib/php7/modules"
	# Tests require extra extensions which are not bundled
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test \
		PHP_TEST_SHARED_EXTENSIONS="
		-d extension=$modules/apcu.so \
		-d extension=$modules/json.so \
		-d extension=$modules/session.so \
		-d extension=modules/$_pkgreal.so"
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	install -d "$pkgdir"/etc/php7/conf.d
	echo "extension=$_pkgreal.so" > \
		"$pkgdir"/etc/php7/conf.d/10_$_pkgreal.ini
}

sha512sums="35b99bbaa9378cf74e263dc2382390919a4a9be48ff670a09552aa6d132a1d8e22086267e46c2eb3b6d2482d61bbaf638d3bae905bb9ca62590a0ea098551b90  php7-pecl-igbinary-3.1.4.tgz"
